<?php

class Event
{
	protected $_id;
	protected $_fullName;
	protected $_shortName;
	protected $_startDate;
	protected $_endDate;
	protected $_sportsEvent_id;
	
	public function __construct(array $donnees)
	{
		$this->hydrate($donnees);
	}
	
	public function hydrate(array $donnees)
	{
		foreach($donnees as $key => $value)
		{
			$method = 'set'. ucfirst($key);
			if(method_exists($this, $method))
			{
				$this->$method($value);
			}
		}
	}
	
	public function id(){ return $this->_id; }
	public function fullName(){ return $this->_fullName; }
	public function shortName(){ return $this->_shortName; }
	public function startDate(){ return $this->_startDate; }
	public function endDate(){ return $this->_endDate; }
	public function sportsEvent_id(){ return $this->_sportsEvent_id; }
	
	public function setId($id)
	{
		$id = (int) $id;
		if(is_int($id))
		{
			$this->_id = $id;
		}
	}
	public function setFullName($fullName)
	{
		$fullName = (string) $fullName;
		if(is_string($fullName))
		{
			$this->_fullName= $fullName;
		}
	}
	public function setShortName($shortName)
	{
		$shortName = (string) $shortName;
		if(is_string($shortName))
		{
			$this->_shortName= $shortName;
		}
	}
	public function setStartDate($startDate)
	{
		$startDate = (string) $startDate;
		if(is_string($startDate))
		{
			$this->_startDate= $startDate;
		}
	}
	public function setEndDate($endDate)
	{
		$endDate = (string) $endDate;
		if(is_string($endDate))
		{
			$this->_endDate= $endDate;
		}
	}
	public function setSportsEvent_id($sportsEventId)
	{
		$sportsEventId = (int) $sportsEventId;
		if(is_int($sportsEventId))
		{
			$this->_sportsEvent_id = $sportsEventId;
		}
	}
	
	public function getFiltersTime()
	{
		$filtersTime = array(
			"days" => array(),
			"weeks" => array(),
			"months" => array(),
			"years" => array()
		);
		$days = array();
		$currentDay = $this->_startDate;
		if($currentDay != $this->_endDate)
		{
			$days[] = $currentDay;
			$currentDay = "J+1"; ///A terminer
		}
		$weeks = array();
		$months = array();
		$years = array();
	}
	
}